<?php

namespace App\Support;

use DB;
use App\User;
use App\Model\Comment;
use Exception;
use ReflectionClass;
use App\Admin;

trait TestTrait
{
    public function test()
    {   
        echo $this->name;

        //反射取出常量
        $a=$this->commentType();
        return $a;   
        
    }

    protected function commentType()
    {
        $subject = strtoupper(__CLASS__);

        $position = strrpos($subject, '\\');

        if ($position !== false) {
            $subject = substr($subject, $position+1);
        }

        $comment = new ReflectionClass(Admin::class);

        return $comment->getConstant($subject.'_TYPE');
    }
}
